package com.li.jiang.controller;


import cn.hutool.core.collection.CollUtil;
import com.li.jiang.obj.dto.UserLoginData;
import com.li.jiang.obj.pojo.Menu;
import com.li.jiang.service.impl.MenuServiceImpl;
import com.li.jiang.utils.ReturnMessage;
import com.li.jiang.utils.localThread.UserThreadLocal;
import com.li.jiang.utils.redis.RedisUtil;
import com.li.jiang.utils.role.RequireRoles;
import com.li.jiang.utils.role.Role;
import com.li.jiang.utils.token.TokenUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.Collections;
import java.util.List;

/**
 * <p>
 * 菜单表 前端控制器
 * </p>
 *
 * @author 李江
 * @since 2024-04-12
 */
@RestController
@RequestMapping("/menu")
public class MenuController {
    @Autowired
    private MenuServiceImpl menuService;
    @Autowired
    private RedisUtil redisUtil;

    @RequireRoles(role = {Role.ADMIN,Role.COMPANY,Role.STUDENT,Role.TOURIST})
    @GetMapping("/getMenus")
    public ReturnMessage getMenus(){
        List<Menu> menus = menuService.getMenus();
        if (CollUtil.isEmpty(menus)){
            return new ReturnMessage("角色信息错误",201,"","");
        }
        return new ReturnMessage("菜单获取成功",200,menus,null);
    }
}
